var t = require("../../../@babel/runtime/helpers/interopRequireDefault"), a = require("../../../@babel/runtime/helpers/objectSpread2"), e = t(require("../../../dist/dialog/dialog")), i = getApp();

Page({
    data: {
        domainName: "领域名称",
        option2: [ {
            text: "由近到远",
            value: 1
        }, {
            text: "由远到近",
            value: 2
        } ],
        categoryList: [],
        text: "距离",
        form: {
            distance_type: "",
            name: "",
            lng: "",
            lat: "",
            category_id: ""
        },
        point: [],
        myLocation: {},
        isLoadMore: !0,
        page: 1,
        last_page: 1
    },
    onLoad: function(t) {},
    onSearch: function(t) {
        var a = this;
        this.setData({
            "form.name": t.detail
        }), this.timerId && clearTimeout(this.timerId), this.timerId = setTimeout(function() {
            a.getSearch();
        }, 300);
    },
    onReady: function() {},
    onShow: function() {
        this.getCategory(), this.getSearch();
    },
    getSearch: function() {
        var t = this, o = wx.getStorageSync("address-point");
        o && o.point ? (this.data.form.lng = o.point.lng, this.data.form.lat = o.point.lat, 
        "距离" !== this.data.text ? this.data.form.distance_type = "由近到远" == this.data.text ? 1 : 2 : "距离" == this.data.text && (this.data.form.distance_type = 1), 
        i._postNetWork({
            url: i.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer.getLawyerList"),
            data: a({}, this.data.form),
            success: function(a) {
                1 == a.data.result && t.setData({
                    lawyer_info: a.data.data.list,
                    page: a.data.data.list.current_page,
                    last_page: a.data.data.list.last_page
                });
            }
        })) : e.default.confirm({
            title: "提示",
            message: "定位失败,是否跳转手动定位"
        }).then(function() {
            wx.navigateTo({
                url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=suppligoodsOrde"
            });
        }).catch(function() {});
    },
    getCategory: function() {
        var t = this;
        i._postNetWork({
            url: i.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer.getCategory"),
            success: function(a) {
                1 == a.data.result && t.setData({
                    categoryList: a.data.data.category
                });
            }
        });
    },
    domain: function(t) {
        var a = t.currentTarget.dataset.item.title, e = t.currentTarget.dataset.item.id;
        this.data.domainName == a ? this.setData({
            domainName: "领域名称",
            "form.category_id": ""
        }) : this.setData({
            domainName: a,
            "form.category_id": e
        }), this.selectComponent("#dropdown").toggle(), this.getSearch();
    },
    change: function(t) {
        var a = this, e = t.currentTarget.dataset.item.text, i = t.currentTarget.dataset.item.value;
        e == this.data.text ? (this.setData({
            text: "距离",
            distance_type: ""
        }), this.getSearch()) : (this.setData({
            text: e,
            distance_type: i
        }), this.data.form.lng && this.data.form.lat ? this.getSearch() : wx.getLocation({
            type: "gcj02",
            success: function(t) {
                console.log(t), a.setData({
                    "form.lng": t.longitude,
                    "form.lat": t.latitude
                }), a.getSearch();
            }
        })), this.selectComponent("#distance").toggle();
    },
    to: function(t) {
        var a = t.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageI/lawyerPlatform/detail/detail?type_name=lawyer&id=" + a
        });
    },
    onReachBottom: function() {
        var t = this;
        if (this.data.page > this.data.last_page) {
            var a = {};
            this.data.form.name && (a.name = this.data.form.name);
            var e = i.getNetAddresss("plugin.lawyer-platform.frontend.controllers.lawyer.getLawyerList");
            i._postNetWork({
                url: e,
                data: a,
                success: function(a) {
                    1 == a.data.result ? (t.data.lawyer_info.data.concat(a.data.data.list.data), t.setData({
                        lawyer_info: t.data.lawyer_info,
                        page: a.data.data.list.current_page,
                        last_page: a.data.data.list.last_page
                    })) : i.tips(a.data.msg);
                }
            });
        }
    },
    onShareAppMessage: function() {}
});